package com.fake_Interviews.controller;

import com.fake_Interviews.module.Login;
import org.apache.shiro.SecurityUtils;
import org.apache.shiro.authz.annotation.RequiresAuthentication;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;

@RestController
@RequestMapping("/api/v1")
public class User_Controller {
    @GetMapping("/user")
    @RequiresAuthentication
    public ResponseEntity<List<String>> userName() {
        Login user = (Login) SecurityUtils.getSubject().getPrincipal(); // 获取当前登录用户
        List<String> list = new ArrayList<>();
        list.add(user.getUsername());
        return ResponseEntity.status(200).header("Custom-Header","ok").body(list);
    }
}
